package com.edgegateway.system.service.impl;

import java.util.List;
import com.edgegateway.common.utils.DateUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.edgegateway.system.mapper.IotEdgeDevicesMapper;
import com.edgegateway.system.domain.IotEdgeDevices;
import com.edgegateway.system.service.IIotEdgeDevicesService;
import com.edgegateway.common.core.text.Convert;

/**
 * 边缘设备Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-01-03
 */
@Service
public class IotEdgeDevicesServiceImpl implements IIotEdgeDevicesService 
{
    @Autowired
    private IotEdgeDevicesMapper iotEdgeDevicesMapper;

    /**
     * 查询边缘设备
     * 
     * @param id 边缘设备主键
     * @return 边缘设备
     */
    @Override
    public IotEdgeDevices selectIotEdgeDevicesById(String id)
    {
        return iotEdgeDevicesMapper.selectIotEdgeDevicesById(id);
    }

    /**
     * 查询边缘设备列表
     * 
     * @param iotEdgeDevices 边缘设备
     * @return 边缘设备
     */
    @Override
    public List<IotEdgeDevices> selectIotEdgeDevicesList(IotEdgeDevices iotEdgeDevices)
    {
        return iotEdgeDevicesMapper.selectIotEdgeDevicesList(iotEdgeDevices);
    }

    /**
     * 新增边缘设备
     * 
     * @param iotEdgeDevices 边缘设备
     * @return 结果
     */
    @Override
    public int insertIotEdgeDevices(IotEdgeDevices iotEdgeDevices)
    {
        iotEdgeDevices.setCreateTime(DateUtils.getNowDate());
        return iotEdgeDevicesMapper.insertIotEdgeDevices(iotEdgeDevices);
    }

    /**
     * 修改边缘设备
     * 
     * @param iotEdgeDevices 边缘设备
     * @return 结果
     */
    @Override
    public int updateIotEdgeDevices(IotEdgeDevices iotEdgeDevices)
    {
        iotEdgeDevices.setUpdateTime(DateUtils.getNowDate());
        return iotEdgeDevicesMapper.updateIotEdgeDevices(iotEdgeDevices);
    }

    /**
     * 批量删除边缘设备
     * 
     * @param ids 需要删除的边缘设备主键
     * @return 结果
     */
    @Override
    public int deleteIotEdgeDevicesByIds(String ids)
    {
        return iotEdgeDevicesMapper.deleteIotEdgeDevicesByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除边缘设备信息
     * 
     * @param id 边缘设备主键
     * @return 结果
     */
    @Override
    public int deleteIotEdgeDevicesById(String id)
    {
        return iotEdgeDevicesMapper.deleteIotEdgeDevicesById(id);
    }

    @Override
    public void updateByTopic(String tpoic) {
        IotEdgeDevices devices = new IotEdgeDevices();
        devices.setStatus(0);
        iotEdgeDevicesMapper.updateByTopic(devices);
    }

    @Override
    public List<IotEdgeDevices> getAll() {
        return iotEdgeDevicesMapper.getAll();
    }

    @Override
    public IotEdgeDevices getTopic(String topic) {
        return iotEdgeDevicesMapper.getByTopic(topic);
    }

    @Override
    public void updateList(List<IotEdgeDevices> edgeDevicesList) {
        iotEdgeDevicesMapper.updateList(edgeDevicesList);
    }
}
